﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class follow : MonoBehaviour
{
    private float speed = 1;
    public GameObject gameObject;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        // this.transform.position = new Vector3(0, 0.1f, 28);

        if(this.transform.position.z >= 0){
            this.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + 4);
        }
        else{
            this.transform.position = new Vector3(0, 0.001f, 24);
            float x = this.transform.position.x;
            float y = this.transform.position.y;
            float z = this.transform.position.z;
            this.transform.Translate(new Vector3(0,0,0-speed) * Time.deltaTime);
        }

        speed += 0.000002f;
    }
}
